<%--
  Created by IntelliJ IDEA.
  User: qpx
  Date: 2017/12/9
  Time: 22:33
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
    <img src="${url}" alt="">
</body>
<script>

    var ws = new WebSocket("ws://localhost/webserver?userName=123456")
//    ws.onopen = function () {
//        console.log("onpen");
//        //ws.send("{}");
//    }
//    ws.onclose = function () {
//        console.log("onclose");
//    }

    ws.onmessage = function (msg) {
        console.log(msg.data);
        msg = msg.data.split("_");
        if(msg[0] == "websocket"){
            alert(msg[1]);
            if(msg[1]=="登陆成功"){
                location.href="http://www.baidu.com";
                return;
            }
        }

    }

</script>
</html>
